startmoney=3.98
cat $1 |grep -v ^#| while read line;do
        verf=`echo $line | awk -F, -v startmoney=$startmoney '{
            versum=int(startmoney+$3-$4-$5);
            if(versum==0) print 1;else print 0}'`
        nextstartmoney=`echo $line | awk -F, '{print $5}'`
        if [ $verf -eq 1 ];then
            startmoney=$nextstartmoney
        else
            echo $line
            echo -n "$startmoney + "
            echo $line | awk -F, '{OFS="-";print $3,$4,$5}'
            echo "Error"
            break
        fi
    done
cat $1 |grep -v ^#| awk -F, 'BEGIN{outall=0;inall=0;incom[""]=0} 
  {outall+=$4;if($4<0.1){incom[$NF]+=$3;inall+=$3}}  
      END{for(a in incom) print a,incom[a];print "outall="outall,"inall="inall,"bal="inall-outall}'


#sort de201105-20120617.csv | awk -F, '$3 ~ /^.[0-9]*/ && $NF !~ /工资/  {$2="-";incom+=$3;print $1"\t"$2"\t"$3"\t"$NF}END{printf("%.2f\n",incom)}'
#sort de201105-20120617.csv | awk -F, '{if($3>4000 && $3 != 6700){incom+=$3;print $1"\t"$2"\t"$3"\t"$NF}} END{print incom}'
#sort de201105-20120617.csv | awk -F, 'BEGIN{out=0;incom[""]=0}{out+=$4;if($4<0.1) incom[$NF]+=$3} END{for(a in incom) print a,incom[a];print "out="out}'
